﻿<UserControl x:Class="PocketBook.Views.BookPrintPreview"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <ItemsControl x:Name="Pages">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="2" Rows="4" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl cal:View.Model="{Binding Page}" Width="{Binding Page.Size.Width}" Height="{Binding Page.Size.Height}">
                        <ContentControl.LayoutTransform>
                            <RotateTransform CenterX="0.5" CenterY="0.5" Angle="{Binding Rotation}" />
                        </ContentControl.LayoutTransform>
                    </ContentControl>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <!-- Gridlines -->
        <Grid>
            <Grid.Resources>
                <Style TargetType="{x:Type Rectangle}">
                    <Setter Property="Stroke" Value="#80808080" />
                    <Setter Property="StrokeDashArray" Value="4,2" />
                    <Setter Property="VerticalAlignment" Value="Top" />
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Rectangle Grid.Row="0" Grid.RowSpan="4" Width="1pt" VerticalAlignment="Stretch" />
            <Rectangle Grid.Row="1" Height="1pt" />
            <Rectangle Grid.Row="2" Height="1pt" />
            <Rectangle Grid.Row="3" Height="1pt" />
        </Grid>
    </Grid>
</UserControl>
